<template>
  <div class="container">
      <el-card class="mt15 mb15">
        <div class="filter-container">
            权益名称：
            <el-input placeholder="请输入内容" v-model="query.a" clearable style="width: 160px;" class="mr20"></el-input>
            
            企业名称：
            <el-input placeholder="请输入内容" v-model="query.b" clearable style="width: 160px;" class="mr20"></el-input>
            
            订单号：
            <el-input placeholder="请输入内容" v-model="query.c" clearable style="width: 160px;" class="mr20"></el-input>
            <el-button class="filter-item" type="primary" icon="el-icon-search">查询</el-button>
        </div>
        <div class="filter-container">
            <el-button type="danger" icon="el-icon-document-delete">删除</el-button>
        </div>
        <el-table
            :key="tableKey"
            v-loading="listLoading"
            :data="list"
            fit
            stripe
            highlight-current-row
            style="width: 100%;"
            @sort-change="sortChange"
            >
                <el-table-column
                type="selection"
                width="50"
            />
            <el-table-column label="订单编号" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="购买用户" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="所属企业" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="支付金额/元" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="支付方式" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="支付时间" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="生效起止日期" sortable="custom" align="center" width="131"></el-table-column>
            <el-table-column label="操作" align="center" width="131">
                 <el-button type="text" @click="detailsShow()">详情</el-button>
            </el-table-column>
        </el-table>

        <pagination
            v-show="total>0"
            :total="total"
            prev-text="上一页"
            next-text="下一页"
            layout="prev, pager, next, jumper"
            :page.sync="listQuery.page"
            :limit.sync="listQuery.limit"
            @pagination="getList"
            />
    </el-card>

    <order-details  ref="orderDetails"/>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import orderDetails from './components/details'
export default {
  components: {orderDetails,Pagination},
  props: {},
  data() {
    return {
        query: {},
        tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
    };
  },
// 方法
  methods: {
    getList() {
      this.listLoading = true;
       this.list = [''],
      this.total = 1
      setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
    },
    // 搜索
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    // 排序
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    },
      // 显示详情弹窗
      detailsShow(){
        this.$refs.orderDetails.show();
      }
  },
// 生命周期 - 创建完成（可以访问当前this实例）
  created() {
      this.getList();
  },
// 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
// 销毁
  destroyed() {}
};
</script>
<style lang="scss" scoped>
  .container{
      .filter-container{
        line-height: 36px;
        font-size: 14px;
        margin-bottom: 10px;
        .filter-item{
        margin-bottom: 0;
        }
    }
  }
</style>